package Logg_Inn;

import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.BoxLayout;
import javax.swing.WindowConstants;

public class Melding_Slett{

    JFrame frame;
    JPanel panelSuperior, panelInferior, panelIntermedio;
    JButton bt1, bt2;
    JTextField pantalla;
    PropertyChangeSupport pcs;
    JLabel mensaje = new JLabel("<html>Er du sikker p� at du vil slette avtalen?<br> En beskjed vil blir sendt til de ber�rte personene, <br>du kan legge ved en beskjed</html>", JLabel.CENTER);

    public Melding_Slett(){
    	pcs = new PropertyChangeSupport(this);
        construyePanelSuperior();
        construyePanelIntermedio();
        construyePanelInferior();
        construyeVentana();}

    void construyePanelSuperior(){
        panelSuperior = new JPanel ();
        panelSuperior.setLayout(new FlowLayout());
        //pantalla = new JTextField(20);
        panelSuperior.add(mensaje);
        //panelSuperior.add(pantalla);
        }
    void construyePanelIntermedio(){
        panelIntermedio = new JPanel ();
        panelIntermedio.setLayout(new GridLayout(2, 2, 4, 4));
        pantalla = new JTextField(40);
        //panelSuperior.add(mensaje);
        panelIntermedio.add(pantalla);
    	
    }

    void construyePanelInferior(){
        panelInferior= new JPanel();
        panelInferior.setLayout(new GridLayout(1,2,4,4));
        //pantalla = new JTextField(20);
       // panelInferior.add(pantalla);
        bt1=new JButton("Godta");
        bt1.addActionListener(new ActionListener() {
        	public void actionPerformed(ActionEvent e) {
        		String komment = pantalla.getText();
        		pcs.firePropertyChange("godtatt", null, komment);
        		frame.setVisible(false);
        	}
        });
        bt2=new JButton("Avbryt");
        bt2.addActionListener(new ActionListener() {
        	public void actionPerformed(ActionEvent e) {
        		pcs.firePropertyChange("avbrutt", null, null);
        		frame.setVisible(false);
        	}
        });
        panelInferior.add(bt1);
        panelInferior.add(bt2);
        
    }
        
    void construyeVentana(){
        frame =new JFrame("Slett Melding ");
        frame.setLayout(new BoxLayout(frame.getContentPane(),BoxLayout.Y_AXIS));
        frame.add(panelSuperior);
        frame.add(panelIntermedio);
        frame.add(panelInferior);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);}
    
    public void addPropertyChangeListener(PropertyChangeListener listener) {
    	pcs.addPropertyChangeListener(listener);
    }

    public static void main(String [] inforux){
        new Melding_Slett();}
 } // fin de la clase DemoGridLayout}